Skip to content

Harden string-based rendering - #21

Merged
blackopsrepl merged 3 commits into
mainfrom
issue-3-safe-html-rendering
Mar 21, 2026
Merged

Harden string-based rendering#21
blackopsrepl merged 3 commits into
mainfrom
issue-3-safe-html-rendering

Conversation

@blackopsrepl

Copy link
Copy Markdown
Contributor

Summary

  • Make SF.el text-safe by default and add explicit unsafeHtml key.
  • Keep modal/tab/table/gantt/tostring content rendering in text mode by default.
  • Add explicit opt-in fields for raw HTML insertion (unsafeBody, tabs[].content.unsafeHtml, cells[].unsafeHtml, unsafePopupHtml, columns[].render(task).unsafeHtml).
  • Document unsafe rendering APIs in README.
  • Regenerate bundled static/sf/sf.js.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51fd5a97c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread js-src/06-modal.js Outdated
Comment on lines +78 to +81
if (typeof content === 'string') {
target.textContent = content;
} else if (content && content.unsafeHtml) {
target.innerHTML = content.unsafeHtml;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat unsafeBody as raw HTML in modal helper

The new modal API advertises unsafeBody as the opt-in HTML hook, but this helper only switches to innerHTML when content.unsafeHtml exists. If a consumer follows the new API and passes unsafeBody: '<strong>...</strong>', the markup is still written through textContent, so both the initial modal body and any later setBody() updates render the literal tags instead of HTML.

Useful? React with 👍 / 👎.

Comment thread js-src/14-gantt.js Outdated

chartContainer.innerHTML = '<svg id="' + svgId + '"></svg>';
chartContainer.textContent = '';
chartContainer.appendChild(sf.el('svg', { id: svgId }));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Create the Gantt root with an SVG namespace

Replacing the parser-created '<svg ...>' with sf.el('svg', ...) changes the chart root to document.createElement('svg'). Frappe Gantt's vendored setup_wrapper() reuses any existing child svg instead of creating its own root (static/sf/vendor/frappe-gantt/frappe-gantt.min.js), so on browsers that require createElementNS for SVG nodes the library will append rect/g children under a non-SVG element and the chart can render blank.

Useful? React with 👍 / 👎.

@blackopsrepl
blackopsrepl merged commit a13ae86 into main Mar 21, 2026
1 check passed
@blackopsrepl
blackopsrepl deleted the issue-3-safe-html-rendering branch March 21, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant